package jsonDyska;



import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JSONExample {
	
	public static void main(String[] args) throws IOException {
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
		
		Person mara = new Person();
		mara.setName("Mara");
//		mara.setPhone("43432432");
		mara.setAddress(new Address("Plovdiv", "Maina 5"));
		
//		Map<String,Integer> alcohol = new HashMap<String,Integer>();
//		ArrayList<String> list = new ArrayList<String>();
//		Collections.addAll(list, "rakiq", "bira", "menta","vodka", "rome", "whiskey");
//		ArrayList<Integer> listq = new ArrayList<Integer>();
//		Collections.addAll(listq, 3, 2, 3,7, 3, 9);
//		
//		for (int i=0; i<list.size(); i++)
//			alcohol.put(list.get(i), listq.get(i));
//		
//		PrintWriter wr = new PrintWriter(new File("Mara.json"));
//		wr.write(gson.toJson(mara));
//		wr.close();
		
		Scanner sc = new Scanner(new File("Mara.json"));
		StringBuffer buf = new StringBuffer();
		while (sc.hasNext()) buf.append(sc.nextLine());
		
		ArrayList list = gson.fromJson(buf.toString(),ArrayList.class);
		System.out.println(list.get(0));
	}
}
